<?php
/**
 * Created by PhpStorm.
 * Author: 芸签cms www.yunqiancms.com
 * User: sun
 * Date: 2022/8/1
 * Time: 12:58 PM
 */

namespace app\common\services\theme;

use app\common\exceptions\BizException;
use app\common\services\theme\datas\Carousel;
use app\common\services\theme\datas\CategoryList;
use app\common\services\theme\datas\NavMenuList;

class ConfigDataFactory
{

    const TYPE_CATEGORY_LIST = 'categoryList';
    const TYPE_CAROUSEL = 'carousel';
    const TYPE_NAV_MENU_LIST = 'navMenuList';
    public static function create($type){
        $obj = null;
        switch ($type){
            case self::TYPE_CAROUSEL:
                $obj = new Carousel();
                break;
            case self::TYPE_CATEGORY_LIST:
                $obj = new CategoryList();
                break;
            case self::TYPE_NAV_MENU_LIST:
                $obj = new NavMenuList();
                break;
            default:
                throw new BizException('创建数据类失败,'.$type.'类型不存在');
                break;
        }
        return $obj;
    }
}